From ec51c633139911162bccdecf0c26d331abda5c10 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Timm=20B=C3=A4der?= Date: Sat, 20 May 2017 19:32:16 +0200 Subject: [PATCH] widget: Bring resize and baseline debug rendering back --- gtk/gtkwidget.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c index f45a3989dc..1dbd9eb521 100644 --- a/gtk/gtkwidget.c +++ b/gtk/gtkwidget.c @@ -15355,6 +15355,59 @@ gtk_widget_reset_controllers (GtkWidget *widget) } } +static inline void +gtk_widget_maybe_add_debug_render_nodes (GtkWidget *widget, + GtkSnapshot *snapshot) +{ + GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget); + GdkDisplay *display = gtk_widget_get_display (widget); + + if (GTK_DISPLAY_DEBUG_CHECK (display, BASELINES)) + { + int baseline = gtk_widget_get_allocated_baseline (widget); + + if (baseline != -1) + { + GdkRGBA black = {1, 0, 0, 1}; + graphene_rect_t bounds; + + style = gtk_css_node_get_style (priv->cssnode); + get_box_margin (style, &margin); + get_box_border (style, &border); + get_box_padding (style, &padding); + + /* Baselines are relative to the widget's origin, + * and we are offset to the widget's allocation here */ + graphene_rect_init (&bounds, + 0, + margin.top + border.top + padding.top + baseline, + priv->allocation.width, 1); + gtk_snapshot_append_color (snapshot, + &black, + &bounds, + "Baseline Debug"); + } + } + + if (GTK_DISPLAY_DEBUG_CHECK (display, RESIZE) && + priv->highlight_resize) + { + GdkRGBA red = {1, 0, 0, 0.2}; + graphene_rect_t bounds; + + graphene_rect_init (&bounds, + 0, 0, + priv->allocation.width, priv->allocation.height); + + gtk_snapshot_append_color (snapshot, + &red, + &bounds, + "Baseline Debug"); + priv->highlight_resize = FALSE; + gtk_widget_queue_draw (widget); + } +} + void gtk_widget_snapshot (GtkWidget *widget, GtkSnapshot *snapshot) @@ -15481,6 +15534,11 @@ gtk_widget_snapshot (GtkWidget *widget, gtk_css_filter_value_pop_snapshot (filter_value, snapshot); +#ifdef G_ENABLE_DEBUG + gtk_widget_maybe_add_debug_render_nodes (widget, snapshot); +#endif + + if (GTK_DEBUG_CHECK (SNAPSHOT)) gtk_snapshot_pop (snapshot); } -- 2.30.2